package cn.tedu.store.config.mybatisPlus;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {
    /**
     * 新增分页拦截器，并设置数据库类型为mysql
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        //MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        ////添加数据权限处理器，注意顺序，先数据权限再分页
        //MyDataPermissionInterceptor dataPermissionInterceptor = new MyDataPermissionInterceptor();
        //// 添加自定义的数据权限处理器
        //dataPermissionInterceptor.setDataPermissionHandler(new MyDataPermissionHandler());
        //interceptor.addInnerInterceptor(dataPermissionInterceptor);
        //interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return interceptor;
    }

}
